//////////////////////////////////////////////////////////////////////////////////////////////
//	File			:	"Emitter.h"
//
//	Author			:	Mike Davis, Matt Stover, James Thornton, Keith Webster
//	
//	Project			:	TacWars
//
//	Last Modified	:	11/6/2013
//
//	Purpose			:	
//
//////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "Particle.h"
#include "../../SGD Wrappers/SGD_Math.h"
#include "../../SGD Wrappers/CSGD_Direct3D.h"
#include "../../SGD Wrappers/CSGD_TextureManager.h"

#include <vector>
using namespace std;

class Entity;

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>


enum EmitterType { DOT, RECTANGLE, CIRCLE, LINE };

class Emitter
{
	string				name;
	bool				playing;
	EmitterType			eType;
	Entity*				following;
	vector<Particle*>	particles;
	POINT				emitScale;
	POINT				emitPos;
	float				minSpeed;
	float				maxSpeed; 
	bool				isLooping;
	int					partTextureId;
	int					maxParticles;
	float				emissionRate;
	float				minLife;
	float				maxLife;
	tVector2D			emitDir;
	float				minDir; 
	float				maxDir; 
	tVector2D			minScale;
	tVector2D			maxScale;
	float				rotationRate;
	D3DCOLOR			startColor;
	D3DCOLOR			finColor;

	float				timeSince;
	
	
	
	

	//Set up pointer to TextureManager
	CSGD_TextureManager*	pTM;

public:
	Emitter(string _name, int particleTexture, EmitterType _eType = DOT, Entity* _following = NULL, int _scaleX =1, int _scaleY=1, 
		int _posX=200, int _posY=200, int _maxParticles=100, float _emissionRate=25, float _minLife=3, float _maxLife=3,
		float _minSpeed=10, float _maxSpeed=50, float _emitDirX=0, float _emitDirY=-1, float _minDir=-(3.14159/4), float _maxDir=(3.14159/4), 
		int _minScaleX=1, int _minScaleY=1,	int _maxScaleX=2, int _maxScaleY=2, float _rotationRate=(3.14159/2),
		D3DCOLOR _startColor=D3DCOLOR_ARGB(255,255,0,0), D3DCOLOR _finColor=D3DCOLOR_ARGB(25,0,0,255), bool _looping = true);

	void Update(float dt);
	void Render();
	
	//Accessors////////////////////////////////////////////////////
	string				GetName()		{ return name;			}
	bool				GetPlaying()	{ return playing;		}
	EmitterType			GetType()		{ return eType;			}
	Entity*				GetFollow()		{ return following;		}
	POINT				GetEmitScale()	{ return emitScale;		}
	POINT				GetEmitPos()	{ return emitPos;		}
	float				GetMinSpd()		{ return minSpeed;		}
	float				GetMaxSpd()		{ return maxSpeed;		}
	bool				GetLoop()		{ return isLooping;		}
	//int					GetStuff()		{ return partTextureId;	}
	int					GetMaxPart()	{ return maxParticles;	}
	float				GetERate()		{ return emissionRate;	}
	float				GetMinLife()	{ return minLife;		}
	float				GetMaxLife()	{ return maxLife;		}
	tVector2D			GetEmitDir()	{ return emitDir;		}
	float				GetMinDir()		{ return minDir;		}
	float				GetMaxDir()		{ return maxDir;		}
	tVector2D			GetMinScl()		{ return minScale;		}
	tVector2D			GetMaxScl()		{ return maxScale;		}
	float				GetRotate()		{ return rotationRate;	}
	D3DCOLOR			GetStCol()		{ return startColor;	}
	D3DCOLOR			GetFinCol()		{ return finColor;		}
	///////////////////////////////////////////////////////////////

	//Mutators/////////////////////////////////////////////////////
	void		SetName		( string		n)		{ name			= n;}
	void		SetPlaying	( bool			n)		{ playing		= n;}
	void		SetType		( EmitterType	n)		{ eType			= n;}
	void		SetFollow	( Entity*		n)		{ following		= n;}
	void		SetEmitScale( POINT			n)		{ emitScale		= n;}
	void		SetEmitPos	( POINT			n)		{ emitPos		= n;}
	void		SetMinSpd	( float			n)		{ minSpeed		= n;}
	void		SetMaxSpd	( float			n)		{ maxSpeed		= n;}
	void		SetLoop		( bool			n)		{ isLooping		= n;}
	void		SetStuff	( int			n)		{ partTextureId	= n;}
	void		SetMaxPart	( int			n)		{ maxParticles	= n;}
	void		SetERate	( float			n)		{ emissionRate	= n;}
	void		SetMinLife	( float			n)		{ minLife		= n;}
	void		SetMaxLife	( float			n)		{ maxLife		= n;}
	void		SetEmitDir	( tVector2D		n)		{ emitDir		= n;}
	void		SetMinDir	( float			n)		{ minDir		= n;}
	void		SetMaxDir	( float			n)		{ maxDir		= n;}
	void		SetMinScl	( tVector2D		n)		{ minScale		= n;}
	void		SetMaxScl	( tVector2D		n)		{ maxScale		= n;}
	void		SetRotate	( float			n)		{ rotationRate	= n;}
	void		SetStCol	( D3DCOLOR		n)		{ startColor	= n;}
	void		SetFinCol	( D3DCOLOR		n)		{ finColor		= n;}
	////////////////////////////////////////////////////////////////


};

